package com.hospital;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hospital.pony.base.BaseActivity;
import com.hospital.pony.db.MemberUserUtils;
import com.hospital.pony.model.UserModel;

/**
 * 
 * @author wangxuan 用户信息的展示
 */
public class UserActivity extends BaseActivity {

	// 标题
	private TextView mTvTitle;
	// 返回
	private ImageView mIvBack;
	private TextView mName;
	private String state;
	private RelativeLayout mtvUserName;
	private TextView mPhone;
	private TextView mAddress;
	private RelativeLayout mrlPhone;
	private RelativeLayout mrlAddress;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_user);
		
	}

	@Override
	public void onClick(View v) {
		if(v.getId()==R.id.mIvBack){
			UserActivity.this.finish();
		}
		if(v.getId()==R.id.mrlAddress){
			Intent mrlAddress = new Intent(UserActivity.this, UpdatePswdActivity.class);
			startActivity(mrlAddress);
		}
	}

	@Override
	public void initWidget() {


		mtvUserName = (RelativeLayout) findViewById(R.id.mtvUserName);
		mtvUserName.setOnClickListener(this);
		mPhone = (TextView) findViewById(R.id.mPhone);
		mAddress = (TextView) findViewById(R.id.mAddress);
		mrlPhone = (RelativeLayout) findViewById(R.id.mrlPhone);
		mrlAddress = (RelativeLayout) findViewById(R.id.mrlAddress);
		
		mIvBack = (ImageView) findViewById(R.id.mIvBack);
		mTvTitle = (TextView) findViewById(R.id.mTvTitle);
		mName = (TextView) findViewById(R.id.mName);

		mTvTitle.setText("我的资料");
		mIvBack.setVisibility(View.VISIBLE);
		mIvBack.setOnClickListener(this);
		mrlAddress.setOnClickListener(this);

	}

	@Override
	public void initData() {

		try {
			UserModel userModel = (UserModel) MemberUserUtils.getBean(this, "user_messgae");
			mName.setText("用户名称： " + MemberUserUtils.getName(this));
			mPhone.setText("手机号码： " + userModel.getUphone());
	
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	
	@Override
	protected void onResume() {
		super.onResume();
		initWidget();
		initData();
	}
}
